mui.init({
	swipeBack: false, //右滑关闭功能
});

if (window.plus) {
	plusReady();
} else {
	document.addEventListener('plusready', plusReady, false);
}
//设置首次刷新时间
var first = null;

function plusReady() {
	document.addEventListener('loadHasdoData',initdata);
}

function initdata(event) {
	var xtbh = event.detail.xtbh;
	var token = plus.storage.getItem("token");
	if (token == null || token == "") {
		return;
	} else {
		panUtil.ajaxLoding.start();
		mui.ajax(baseServerAdrr+'/zc/getYbList', {
			data: {
				token: token,
				xtbh: xtbh
			},
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 30000, //超时时间设置为10秒；
			success: function(data) {
				panUtil.ajaxLoding.stop();
				if (data.code == 'success') {
					//console.log(JSON.stringify(data));
					var table = $('.mui-table-view');
					table.html(""); //清空一下数据
					var sys = data.message[0];
					var tablestr = "<li class='mui-table-view-cell mui-checkbox mui-left pan_todo_title_li'>";
					tablestr += '<img class="pan_todo_img" src="../' + sys.xttp + '"><span class="pan_todo_span">' + sys.xtmc + '</span></li>';
					var sylist = sys.lists;
					if (sylist == null) {
						table.html(tablestr);
						return;
					}
					for (var j = 0; j < sylist.length; j++) {
						var syl = sylist[j];
						tablestr += '<li class="mui-table-view-cell">';
						tablestr += '<a href="javascript:void(0)"  onclick="listclick(\'' + syl.BIZ + '\',\'' + syl.BIZNAME + '\')" class="mui-navigate-right mui-a-href pan_font_color">' + syl.BIZNAME + '<span class="mui-badge mui-badge-danger">' + syl.NUM + '</span></a>';
						tablestr += '</li>';
					}
					table.html(tablestr);

				} else {
					mui.toast(data.message);
					setTimeout(function() {
						panUtil.ReLogin();
					}, 1000);
				}
			},
			error: function(xhr, type, errorThrown) {
				panUtil.ajaxLoding.stop();
				//异常处理；
				mui.toast('服务器异常登录失败!');
			}
		});
	}
}
//列表点击事件
function listclick(biz, bizname) {
	var listview = mui.openWindow({
		url: 'splb/zcsplbyb.html',
		id:  "zcsplbyb",
		extras: {
			splx: "approved",
			biz: biz,
			bizname: bizname
		},
		createNew: false,
		waiting: {
			autoShow: false
		}
	});
}